!<template>
  <div>
    <!-- 历史记录 -->
    <div class="his-hot" v-show="isShowHisttory">
      <div class="hd">
        <h4>历史记录</h4>
        <van-icon name="delete" @click="clearHistory" />
      </div>
      <div id="bd">
        <van-tag
          @click="tagClick(item)"
          v-for="(item, index) in historyKeywordList"
          plain
          type="default"
          :key="index"
          >{{ item }}</van-tag
        >
      </div>
    </div>

    <!-- 热门搜索 -->
    <div class="his-hot">
      <div class="hd">
        <h4>热门搜索</h4>
        <van-icon name="delete" />
      </div>
      <div id="bd">
        <van-tag
          @click="tagClick(item.keyword)"
          v-for="(item, index) in hotKeywordList"
          plain
          type="default"
          :key="index"
          :class="index == 0 ? 'red' : ''"
          >{{ item.keyword }}</van-tag
        >
      </div>
    </div>
  </div>
</template>
<script>
import { ClearHistory } from "@/request/api";
export default {
  components: {},
  data() {
    return {
      isShowHisttory: true,
    };
  },
  props: ["historyKeywordList", "hotKeywordList"],
  //   方法集合
  methods: {
    clearHistory() {
      ClearHistory().then((res) => {
        if (res.errno == 0) {
          // 提示删除成功
          this.$toast.success("删除成功");
          setTimeout(() => {
            // 隐藏“历史记录”  的  div 盒子
            this.isShowHisttory = false;
          });
        }
      });
    },
    tagClick(tagVal) {
      this.$emit("tagClick", tagVal);
    },
  },
  // 声明周期  -  创建完成（可以访问当前this示例）
  created() {},
};
</script>
<style lang="less" scoped>
.his-hot {
  background-color: #fff;
  padding: 0.1rem;
  margin-bottom: 0.2rem;
  .red {
    color: red;
  }
  .hd {
    display: flex;
    justify-content: space-between;
    font-size: 0.2rem;
    margin-bottom: 0.09rem;
    h4 {
      font-size: 0.2rem;
    }
  }
  .van-tag {
    margin-right: 0.05rem;
    padding: 0.02rem 0.03rem;
    margin-top: 0.05rem;
  }
}
</style>